﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 排序短发_冒泡排序
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] arr = {3, 4, 1, 9, 2, 6 };

            for (int j = 0; j < arr.Length - 1; j++)
            {
                //一次冒泡
                for (int i = 0; i < arr.Length - 1 - j; i++)
                {
                    if (arr[i] > arr[i + 1])
                    {
                        int tmpe = arr[i];
                        arr[i] = arr[i + 1];
                        arr[i + 1] = tmpe;
                    }
                }
            }

            //遍历数组
            foreach (var item in arr)
            {
                Console.WriteLine(item);
            }
        }
    }
}
